package com.zzyl.nursing.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyl.nursing.domain.Reservation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @author Waker
 * @description:
 * @create 2025-09-13-21:57
 */
@Mapper
public interface MemberReservationMapper extends BaseMapper<Reservation> {
    /**
     * 查询指定时间段内预约数量
     * @param startTime
     * @param endTime
     * @return
     */
    @Select("SELECT time, 6 - COUNT(*) AS count FROM reservation WHERE time BETWEEN #{startTime} AND #{endTime} AND status != 2 GROUP BY time")
    List<Map<String, Object>> countByTime(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
}
